home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16284 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.6 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
  4. Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
  5. Date: 9 Apr 1996 19:29:15 -0700
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4kf6drINN4pg@keats.ugrad.cs.ubc.ca>
  8. References: <JSA.96Feb16135027@organon.com> <dewar.829054330@schonberg> <4ke0ciINNgg8@keats.ugrad.cs.ubc.ca> <EACHUS.96Apr9184019@spectre.mitre.org>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <EACHUS.96Apr9184019@spectre.mitre.org>,
  12. Robert I. Eachus <eachus@spectre.mitre.org> wrote:
  13. >
  14. >    I hope that everyone following this thread knows that this
  15. >"undefined" behavior lead to one of the security holes exploited by
  16. >the Morris Internet worm.
  17.  
  18. No, this was something to do with gets being applied to an automatic buffer.
  19. If you picture the downward growing stack on a Sun3 or VAX, imagine what you
  20. can do if you can overrun a stack array variable with bytes that spell out
  21. machine code. If you are clever, you can overwrite the buffer in such a way
  22. that the return address on the stack is modified to jump to the other portions
  23. of your array. This can be done thanks to absolute addressing on a machine with
  24. virtual address spaces, where each process always starts out with the same
  25. stack pointer value. Once you jump to your array, you have control of the
  26. machine. You can do system calls galore---and if you are running under euid 0,
  27. you are God.
  28.  
  29. I should try this under Linux just for fun.
  30.  
  31. The POSIX.1 standard was not even around then, by the way.
  32.  
  33. >    Undefined only means unusable in some contexts, and if the C read
  34. >had a way to know the size of the buffer passed, that particular
  35. >security hole would not have existed.
  36.  
  37. That much is true, modulo s/read/gets/
  38.  
  39. The read function has a way to know the buffer size, namely the nbytes
  40. argument. (There is no read in C, by the way) The gets() function has no such
  41. argument and should be avoided like the plague except in totally trivial,
  42. makeshift programs or in debugging.
  43.  
  44. There are still some old-timer bugs that plague (commercial) UNIX: try typing a
  45. !%s%s%s%s  command to the C shell (not tcsh, but the more crappy real one that
  46. you actually _pay_ for when you buy a SVR4 unix).   It tries to tell you that
  47. the %s%s%s%s event is not found in the history. But guess what? It uses
  48. raw printf(), so the %s's get interpreted as format strings. The function looks
  49. for non-existent arguments, resulting in strange behavior, like crap being
  50. printed on the terminal.
  51. -- 
  52.  
  53.